VERSION = 0.01
XML_MAIN = holtei-1.xml
XML_INCLUDES = h1-div-01.xml h1-div-02.xml h1-div-03.xml h1-div-04.xml	\
 h1-div-05.xml h1-div-06.xml h1-div-07.xml h1-div-08.xml h1-div-09.xml	\
 h1-div-10.xml h1-div-11.xml h1-div-12.xml h1-div-13.xml h1-div-14.xml	\
 h1-div-15.xml h1-div-16.xml h1-div-17.xml h1-div-18.xml h1-div-19.xml	\
 h1-div-20.xml h1-div-21.xml h1-div-22.xml h1-div-23.xml h1-div-24.xml	\
 h1-div-25.xml h1-div-26.xml h1-div-27.xml h1-div-28.xml h1-div-29.xml	\
 h1-div-30.xml h1-div-31.xml h1-div-32.xml h1-div-33.xml h1-div-34.xml	\
 h1-div-35.xml h1-div-36.xml h1-div-37.xml h1-div-38.xml h1-div-39.xml	\
 h1-div-40.xml h1-div-41.xml h1-div-42.xml h1-div-43.xml h1-div-44.xml	\
 h1-div-45.xml h1-div-46.xml h1-div-47.xml h1-div-48.xml h1-div-49.xml	\
 h1-div-50.xml h1-div-51.xml h1-div-52.xml h1-div-53.xml h1-div-54.xml	\
 h1-div-55.xml h1-div-56.xml h1-div-57.xml h1-div-58.xml h1-div-59.xml	\
 h1-div-60.xml h1-div-61.xml h1-div-62.xml h1-div-63.xml h1-div-64.xml	\
 h1-div-65.xml
XML_FILES = $(XML_MAIN) $(XML_INCLUDES)
outdir = $(basename $(XML_MAIN))
VALID_FILE = $(XML_MAIN:.xml=.valid)
TEI_FILE = $(XML_MAIN:.xml=.tei)
HTML_FILE = $(XML_MAIN:.xml=.html)


tei: $(TEI_FILE)
$(TEI_FILE): $(VALID_FILE) $(XML_FILES)
	@echo $@
	xmllint -o $@ --noent --xinclude --postvalid --nonet $(XML_MAIN)

html: $(outdir)/$(HTML_FILE)
$(outdir)/$(HTML_FILE): $(TEI_FILE)
	mkdir -p $(outdir)
	/usr/share/xml/gnutenberg/0.4/transform.pl -f html $< $(outdir)
	mv $(outdir)/99999-h.html $(outdir)/$(HTML_FILE)
#	rm -f $(outdir)/*.zip

validate: $(VALID_FILE)
$(VALID_FILE): $(XML_FILES)
	true
#	rm -f $@
#	xmllint --noout --postvalid --noent --nonet $(XML_MAIN) && touch $@

.PHONY:
dist: $(outdir)/$(HTML_FILE)
	mkdir -p $(outdir)-$(VERSION)
	cp -p $(outdir)/$(HTML_FILE) $(outdir)-$(VERSION)/$(HTML_FILE)
	tar cjvf $(outdir)-$(VERSION).tar.bz2 $(outdir)-$(VERSION)

# End of Makefile
